from openai import OpenAI
from globle import configs as cfg

client = OpenAI(api_key=cfg.DEEPSEEK_API_KEY, base_url="https://api.deepseek.com")
messages=[{"role": "system", "content": "你是一个作家"}]

def one_chat(text):
    messages.append({"role": "user", "content": text})
    response = client.chat.completions.create(
        model="deepseek-chat", # 必填，模型名称
        messages=messages,
        temperature=2# 温度, 取值0~2, 简单理解是温度越高随机性越强
    )
    messages.append(response.choices[0].message)
    return response.choices[0].message.content

def play():
    print('开始对话吧')
    while True:
        text = input('我：')
        if text == 'exit':
            break
        print('机器人：', one_chat(text))

if __name__ == '__main__':
    play()